import { IpcMainEvent, ipcMain } from 'electron'
import { IPCEvent } from '@common/constant'
import { getWindowByName, getWindowByEvent } from './windows'

ipcMain.on(IPCEvent.OPEN_WINDOW, (_event: IpcMainEvent, name: WindowNameType) => {
  getWindowByName(name).show()
})

ipcMain.on(IPCEvent.CLOSE_WINDOW, (_event: IpcMainEvent, name: WindowNameType) => {
  getWindowByName(name).hide()
})

ipcMain.on(
  IPCEvent.IGNORE_MOUSE_EVENT,
  (event: IpcMainEvent, ignore: boolean, options?: { forward: boolean }) => {
    getWindowByEvent(event).setIgnoreMouseEvents(ignore, options)
  }
)
